Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next
Subject: Removing duplicated emails
Feedback Type: Suggestion
Product Area: Notes Client
Technical Area: Customization
Platform: ALL
Release: 8.5.1
Reproducible: Always

I get a lot of Emails which are the same but come via different route (eg direct to me, via a group, via an alias etc) so I often get 2-3 copies of basically the same email (when people use reply all usually). So I created this JAVA Agent to remove the duplicates in my inbox. I am posting in case it is useful to others.

From the inbox viw, use the create menu to create an Agent, select Java and paste the code below in. Rename the agent ScanForDuplicateEmails2Remove (or similar) and save. It should appear on your Inbox actions, click and let it run. If you want to observe the progress open the Java debug console on the tools menu.

This will Delete to Trash so you can check the decisions before permenant delete. I also set an initail Limit of 20 duplicates per run but you can increase this depending on your machine speed and number of emails to process.

// start of Java code

import lotus.domino.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

int dupLimit = 20 ; // limit run to 20 duplicates

int duplicatesFoundi=0;

String curSubject = "";
String curBody = "";
DateTime curDDate;
int curLength=0;

String lastSubject = "";
String lastBody = "";
DateTime lastDDate;
Document lastDoc;
int lastLength=0;

String summaryText="";

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database currentDb = agentContext.getCurrentDatabase();

View vw = currentDb.getView ("By Person"); // this view exists in r8 mail template; may need to change for earlier versions
Document doc = vw.getFirstDocument();
System.out.println ("Initiating Scan of Mail for duplicates - limited to moving max " + dupLimit + " duplicates to trash each run");
duplicatesFoundi=0;
lastDDate = doc.getCreated();
lastDoc=doc;

while ((doc != null) && (duplicatesFoundi<dupLimit) ){
curSubject = doc.getItemValueString("Subject");
curBody = doc.getItemValueString("Body");
curDDate = doc.getCreated();
curLength= curSubject.length();


if (curSubject.equals(lastSubject) ) {
// System.out.println ("SubJect Match:" +curSubject);

if ((curBody.equals(lastBody)) && (curBody.length()>0)) {
duplicatesFoundi++;
System.out.println (" BODY and Subject Match:" +curSubject);
System.out.println(" Duplicate Item # " + duplicatesFoundi + " removed item with date: " + curDDate + " kept item with date: " + lastDDate + " bodysizes = " +curBody.length() + "/" + lastLength);
summaryText += " Duplicate Item # " + duplicatesFoundi + " removed item with date: " + curDDate + " kept item with date: " + lastDDate + " bodysizes = " +curBody.length() + "/" + lastLength +"\n";
summaryText += " BODY and Subject Match:" +curSubject + "\n" ;
doc.appendItemValue("Subject", " *** DUPLICATED ***");
if (doc.save(false,true))
System.out.println("Subject updated with duplicate");
else
System.out.println("Unable to save document with updated subject line");
if (doc.remove(true)) System.out.println("Duplicate removed");
//doc = vw.getFirstDocument();
doc=lastDoc;
}

}

lastSubject = curSubject;
lastBody = curBody;
lastDDate = curDDate;
lastLength = curLength;
lastDoc = doc;
doc = vw.getNextDocument(doc);



}
System.out.println ("Scan complete");

//Messsagebox "Summary of duplicates Found"+summaryText ;

} catch(Exception e) {
e.printStackTrace();
}
}
}



//end of Java Code


Feedback number WEBB8MSCBW created by ~Laura Oprevitchoden on 10/19/2011

Status: Open
Comments:





Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS